package pers.course.week7;

import java.util.Scanner;

public class LongestPrefix{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] strs = new String[3];
        for (int i = 0; i < strs.length; i++) {
            strs[i] = in.next();
        }
        System.out.println(longestCommonPrefix(strs));
    }
    public static String longestCommonPrefix(String[] strs) {
        if (strs == null || strs.length == 0) {
            return "";
        }
        for (int i = 0; i < strs[0].length(); i++) {
            // Get first string's every character
            char c = strs[0].charAt(i);
            // Compare first string's every character with other strings
            for (int j = 1; j < strs.length; j++) {
                if (i == strs[j].length() || strs[j].charAt(i) != c) {
                    return strs[0].substring(0, i);
                }
            }
        }
        return strs[0];
    }
}
